<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>render tags</title>
</head>
<body>
  <script src="../../node_modules/vue/dist/vue.js"></script>
  <div id="app">
    <!-- test -->
    <example :tags="['h1', 'h2', 'h3']"></example>
  </div>
  <script>
    // 实现该组件
    Vue.component('example',{
      props: ['tags'],
      functional: true, // 函数式组件
      render(h, context) {
        console.log(context);
        const {tags} = context.props;
        // context.slot 可以访问插槽
        // context.children 子VNode
        // context.parent
        // h函数接收(String | Object | Function，[Object]表示属性attribute, String | Array子元素)
        const children = tags.map((tag,index)=>h(tag, index));
        return h('div',children);
      }
    })
    new Vue({
      el: '#app'
    })
  </script>
</body>
</html>